package StudyCode.summary.myfile;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class CopyFileWithStreams {
	public static void main(String[] args) {

		String strSourceFile = "E:\\迅雷下载\\test1.txt";
		String strDestinationFile = "E:\\Copy\\test1.txt";

		try {
			FileInputStream fin = new FileInputStream(strSourceFile);
			FileOutputStream fout = new FileOutputStream(strDestinationFile);
			byte[] b = new byte[1024];
			int noOfBytes = 0;
			while ((noOfBytes = fin.read(b)) != -1) {
				fout.write(b, 0, noOfBytes);
			}
			System.out.println("复制成功。");
			fin.close();
			fout.close();
		} catch (FileNotFoundException fnf) {
			System.out.println("文件未找到 :" + fnf);
		} catch (IOException ioe) {
			System.out.println("复制文件发生错误 :" + ioe);
		}
	}
}
